package com.itheima.service;

import com.itheima.R;
import com.itheima.api.PmsSkuStockApi;
import com.itheima.pojo.db.PmsSkuStock;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author chensen
 * @create 2022/10/14/20:19
 */
@Service
public class PmsSkuStockService {
    @DubboReference
    private PmsSkuStockApi pmsSkuStockApi;

    public R update(Long pid, List<PmsSkuStock> skuStockList) {
        pmsSkuStockApi.delete(pid);
        pmsSkuStockApi.insertList(skuStockList, pid);
        return R.success("更新成功");
    }

    public R selectList(Long pid, String keyword) {
        List<PmsSkuStock> pmsSkuStocks = pmsSkuStockApi.selectList(pid, keyword);
        return R.success(pmsSkuStocks);
    }
}
